package com.toocms.jinjuhang.ui.classify

import android.os.Bundle
import androidx.databinding.ObservableField
import com.toocms.jinjuhang.config.Constants
import com.toocms.jinjuhang.data.goods.ZoneItemData
import com.toocms.jinjuhang.ui.commodity.classify.ClassifyCommodityListFgt
import com.toocms.tab.base.BaseViewModel
import com.toocms.tab.base.MultiItemViewModel
import com.toocms.tab.binding.command.BindingAction
import com.toocms.tab.binding.command.BindingCommand

class ClassifyTitleRightItemModel(
    viewModel: BaseViewModel<*>,
    val item: ObservableField<ZoneItemData>
) :
    MultiItemViewModel<BaseViewModel<*>>(viewModel) {

    init {
        itemType = Constants.RecyclerViewItemType.ITEM_TYPE_ONE
    }

    val itemClickBindingCommand = BindingCommand<BindingAction>(BindingAction {
        item.get()?.apply {
            val bundle = Bundle()
            bundle.putString(Constants.BundleKey.KEY_TITLE, name)
            bundle.putString(Constants.BundleKey.KEY_ZONE_ID, zone_id)
            bundle.putString(Constants.BundleKey.KEY_TYPE, type)
            viewModel.startFragment(ClassifyCommodityListFgt::class.java, bundle)
        }

    })
}